package co.gov.medellin.sdep.sisdep.model.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.jdbc.object.MappingSqlQuery;
import org.springframework.jdbc.object.SqlUpdate;

import co.gov.medellin.sdep.sisdep.model.EstAreaSocioecono;

public class EstAreaSocioeconoDAOImpl extends JdbcDaoSupport implements IEstAreaSocioeconoDAO {

    private InsertOperation insertOperation;

    private UpdateOperation updateOperation;

    private DeleteOperation deleteOperation;

    private DeleteByPrimaryKey deleteByPrimaryKey;

    private FindByPrimaryKeyQuery findByPrimaryKeyQuery;

    private FindByIdSolicitudKeyQuery findByIdSolicitudKeyQuery;

    private FindByCriteriaQuery findByCriteriaQuery;

    private FindAllQuery findAllQuery;

    private FindByActiveStateQuery findByActiveStateQuery;

	private static final String SELECT = "SELECT * FROM GES_EST_AREA_SOCIOECONO_T ";
	private static final String WHERE = " WHERE ";
	private static final String PARAMETER = " ?, ";

    public void delete(EstAreaSocioecono estareasocioecono) {
		deleteOperation.execute( estareasocioecono  );
	}

	public void deleteByPrimaryKey(long id) {
		deleteByPrimaryKey.execute(id);
	}

	public EstAreaSocioecono findByPrimaryKey(long login) {
		return findByPrimaryKeyQuery.runQuery(login);
	}

	public EstAreaSocioecono findByIdSolicitudKey(long idSolicitud) {
		return findByIdSolicitudKeyQuery.runQuery(idSolicitud);
	}

	public void insert(EstAreaSocioecono estareasocioecono) {
		insertOperation.execute( estareasocioecono );
	}

	public void update(EstAreaSocioecono estareasocioecono) {
		updateOperation.execute( estareasocioecono );
	}

	public EstAreaSocioecono findByCriteria(EstAreaSocioecono  estareasocioecono) {
		return findByCriteriaQuery.runQuery(estareasocioecono);
	}

	public List load() {
		return findAllQuery.runQuery();
	}

	public EstAreaSocioecono findByActiveState(EstAreaSocioecono  estareasocioecono) {
		return findByActiveStateQuery.runQuery(estareasocioecono);
	}

	public void initDao() {
    	insertOperation   = new InsertOperation( getDataSource() );
    	updateOperation = new UpdateOperation(  getDataSource() );
    	findByCriteriaQuery = new FindByCriteriaQuery(  getDataSource() );
    	findByIdSolicitudKeyQuery   = new FindByIdSolicitudKeyQuery(  getDataSource() );
    	//Desabilitados
    	//deleteOperation = new DeleteOperation(  getDataSource() );
    	//deleteByPrimaryKey = new DeleteByPrimaryKey( getDataSource());
    	//findByPrimaryKeyQuery   = new FindByPrimaryKeyQuery(  getDataSource() );
    	//findAllQuery = new FindAllQuery( getDataSource() );
    	//findByActiveStateQuery = new FindByActiveStateQuery( getDataSource() );
    }

    // ------------- SaveOperation ---------------------------------------
	class InsertOperation extends SqlUpdate	{
		private static final String sql = "INSERT INTO GES_EST_AREA_SOCIOECONO_T ("
				  + " ID, "
				  + " ID_EST_SOCIO_ECONOMICO, "
				  + " VALOR_EGRESO_F_MES, "
				  + " TRABAJA_EPU, "
				  + " PROMEDIO_MES_VENTA, "
				  + " PROMEDIO_MES_GANANCIA, "
				  + " OTRA_ACTIVIDAD, "
				  + " ACTIVIDAD_ALTERNA, "
				  + " NUMERO_DIA, "
				  + " PROMEDIO_MES_VENTA_OA, "
				  + " PROMEDIO_MES_GANANCIA_OA, "
				  + " OTROS_INGRESOS, "
				  + " CONCEPTO_OTROS_INGRESOS, "
				  + " VALOR_OTROS_INGRESOS, "
				  + " VALOR_INGRESO_F_MES, "
				  + " CAPITAL_INVERTIDO, "
				  + " PAGO_BODEGA, "
				  + " VALOR_PAGO_BODEGA, "
				  + " RAZON_VENTA_EPU, "
				  + " OTRA_VENTA_EPU, "
				  + " ARTE_ALTERNO, "
				  + " OTRO_ARTE_ALTERNO, "
				  + " OBSERVACION, "
				  + " ESTADO, "
				  + " USUARIO_CREA, "
				  + " FECHA_CREA "
				  + ") VALUES ("
			  	  + " GES_EST_AREA_SOCIOECONO_SEC.nextVal, "
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + PARAMETER
				  + "SYSDATE"
				  + ")";
		public  InsertOperation(DataSource ds) {
			super(ds,sql);
			//set here required parameters
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			compile();
		}
		public void execute(EstAreaSocioecono estareasocioecono) {
			InsertOperation.this.update( new Object[]{
				estareasocioecono.getIdEstSocioEconomico(),
				estareasocioecono.getValorEgresoFMes(),
				estareasocioecono.getTrabajaEpu(),
				estareasocioecono.getPromedioMesVenta(),
				estareasocioecono.getPromedioMesGanancia(),
				estareasocioecono.getOtraActividad(),
				estareasocioecono.getActividadAlterna(),
				estareasocioecono.getNumeroDia(),
				estareasocioecono.getPromedioMesVentaOa(),
				estareasocioecono.getPromedioMesGananciaOa(),
				estareasocioecono.getOtrosIngresos(),
				estareasocioecono.getConceptoOtrosIngresos(),
				estareasocioecono.getValorOtrosIngresos(),
				estareasocioecono.getValorIngresoFMes(),
				estareasocioecono.getCapitalInvertido(),
				estareasocioecono.getPagoBodega(),
				estareasocioecono.getValorPagoBodega(),
				estareasocioecono.getRazonVentaEpu(),
				estareasocioecono.getOtraVentaEpu(),
				estareasocioecono.getArteAlterno(),
				estareasocioecono.getOtroArteAlterno(),
				estareasocioecono.getObservacion(),
				estareasocioecono.getEstado(),
				estareasocioecono.getUsuarioCrea()
				});
		}
    }

    // ------------- UpdateOperation -------------------------------------
    class UpdateOperation extends SqlUpdate	{
    	private static final String sql = "UPDATE GES_EST_AREA_SOCIOECONO_T SET "
					  + " ID_EST_SOCIO_ECONOMICO = ? ,"
					  + " VALOR_EGRESO_F_MES = ? ,"
					  + " TRABAJA_EPU = ? ,"
					  + " PROMEDIO_MES_VENTA = ? ,"
					  + " PROMEDIO_MES_GANANCIA = ? ,"
					  + " OTRA_ACTIVIDAD = ? ,"
					  + " ACTIVIDAD_ALTERNA = ? ,"
					  + " NUMERO_DIA = ? ,"
					  + " PROMEDIO_MES_VENTA_OA = ? ,"
					  + " PROMEDIO_MES_GANANCIA_OA = ? ,"
					  + " OTROS_INGRESOS = ? ,"
					  + " CONCEPTO_OTROS_INGRESOS = ? ,"
					  + " VALOR_OTROS_INGRESOS = ? ,"
					  + " VALOR_INGRESO_F_MES = ? ,"
					  + " CAPITAL_INVERTIDO = ? ,"
					  + " PAGO_BODEGA = ? ,"
					  + " VALOR_PAGO_BODEGA = ? ,"
					  + " RAZON_VENTA_EPU = ? ,"
					  + " OTRA_VENTA_EPU = ? ,"
					  + " ARTE_ALTERNO = ? ,"
					  + " OTRO_ARTE_ALTERNO = ? ,"
					  + " OBSERVACION = ? ,"
					  + " ESTADO = ? ,"
					  + " USUARIO_MODIFICA = ? ,"
					  + " FECHA_MODIFICA = SYSDATE "
				  	  + WHERE
					  + " ID = ? ";
		public  UpdateOperation(DataSource ds) {
			super(ds,sql);
			//set here required parameters
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.CHAR));
			declareParameter( new SqlParameter(Types.INTEGER));
			compile();
		}
		public void execute(EstAreaSocioecono estareasocioecono) {
			UpdateOperation.this.update( new Object[]{
				estareasocioecono.getIdEstSocioEconomico(),
				estareasocioecono.getValorEgresoFMes(),
				estareasocioecono.getTrabajaEpu(),
				estareasocioecono.getPromedioMesVenta(),
				estareasocioecono.getPromedioMesGanancia(),
				estareasocioecono.getOtraActividad(),
				estareasocioecono.getActividadAlterna(),
				estareasocioecono.getNumeroDia(),
				estareasocioecono.getPromedioMesVentaOa(),
				estareasocioecono.getPromedioMesGananciaOa(),
				estareasocioecono.getOtrosIngresos(),
				estareasocioecono.getConceptoOtrosIngresos(),
				estareasocioecono.getValorOtrosIngresos(),
				estareasocioecono.getValorIngresoFMes(),
				estareasocioecono.getCapitalInvertido(),
				estareasocioecono.getPagoBodega(),
				estareasocioecono.getValorPagoBodega(),
				estareasocioecono.getRazonVentaEpu(),
				estareasocioecono.getOtraVentaEpu(),
				estareasocioecono.getArteAlterno(),
				estareasocioecono.getOtroArteAlterno(),
				estareasocioecono.getObservacion(),
				estareasocioecono.getEstado(),
				estareasocioecono.getUsuarioModifica(),
				estareasocioecono.getId()
				});
		}
    }

    // ------------- DeleteOperation -------------------------------------
    class DeleteOperation extends SqlUpdate	{
		private static final String sql = "DELETE FROM GES_EST_AREA_SOCIOECONO_T "
										+ WHERE
			  	  	  					+ " ID = ? ";
		public DeleteOperation(DataSource ds) {
			super(ds,sql);
			declareParameter( new SqlParameter(Types.NUMERIC) );
			compile();
		}
		public void execute(EstAreaSocioecono estareasocioecono) {
			this.update( new Object[]{
				estareasocioecono.getId()
			});
		}
	}

    // ------------- DeleteByPrimaryKey ----------------------------------
    class DeleteByPrimaryKey extends SqlUpdate	{
		private static final String sql = "DELETE FROM GES_EST_AREA_SOCIOECONO_T "
										+ WHERE + " 1=1 ";
		public DeleteByPrimaryKey(DataSource ds) {
			super(ds,sql);
			compile();
		}	
		public void execute(long id) {
			this.update( new Object[]{
			});
		}	
    }

    // ---- BaseQueryOperation for Mapping ResultSet values --------------
	abstract class BaseQueryOperation extends MappingSqlQuery {
		public BaseQueryOperation(DataSource ds,String sql) {
	   		super(ds,sql);
		}	
		protected Object mapRow(ResultSet rs, int rownum) throws SQLException {
			EstAreaSocioecono estareasocioecono = new EstAreaSocioecono();
				estareasocioecono.setId(new Long(rs.getLong("ID")));
				estareasocioecono.setIdEstSocioEconomico(new Long(rs.getLong("ID_EST_SOCIO_ECONOMICO")));
				estareasocioecono.setValorEgresoFMes(new Long(rs.getLong("VALOR_EGRESO_F_MES")));
				estareasocioecono.setTrabajaEpu(rs.getString("TRABAJA_EPU"));
				estareasocioecono.setPromedioMesVenta(new Long(rs.getLong("PROMEDIO_MES_VENTA")));
				estareasocioecono.setPromedioMesGanancia(new Long(rs.getLong("PROMEDIO_MES_GANANCIA")));
				estareasocioecono.setOtraActividad(rs.getString("OTRA_ACTIVIDAD"));
				estareasocioecono.setActividadAlterna(rs.getString("ACTIVIDAD_ALTERNA"));
				estareasocioecono.setNumeroDia(new Long(rs.getLong("NUMERO_DIA")));
				estareasocioecono.setPromedioMesVentaOa(new Long(rs.getLong("PROMEDIO_MES_VENTA_OA")));
				estareasocioecono.setPromedioMesGananciaOa(new Long(rs.getLong("PROMEDIO_MES_GANANCIA_OA")));
				estareasocioecono.setOtrosIngresos(rs.getString("OTROS_INGRESOS"));
				estareasocioecono.setConceptoOtrosIngresos(rs.getString("CONCEPTO_OTROS_INGRESOS"));
				estareasocioecono.setValorOtrosIngresos(new Long(rs.getLong("VALOR_OTROS_INGRESOS")));
				estareasocioecono.setValorIngresoFMes(new Long(rs.getLong("VALOR_INGRESO_F_MES")));
				estareasocioecono.setCapitalInvertido(new Long(rs.getLong("CAPITAL_INVERTIDO")));
				estareasocioecono.setPagoBodega(rs.getString("PAGO_BODEGA"));
				estareasocioecono.setValorPagoBodega(new Long(rs.getLong("VALOR_PAGO_BODEGA")));
				estareasocioecono.setRazonVentaEpu(rs.getString("RAZON_VENTA_EPU"));
				estareasocioecono.setOtraVentaEpu(rs.getString("OTRA_VENTA_EPU"));
				estareasocioecono.setArteAlterno(rs.getString("ARTE_ALTERNO"));
				estareasocioecono.setOtroArteAlterno(rs.getString("OTRO_ARTE_ALTERNO"));
				estareasocioecono.setObservacion(rs.getString("OBSERVACION"));
				estareasocioecono.setEstado(rs.getString("ESTADO"));
				estareasocioecono.setUsuarioCrea(rs.getString("USUARIO_CREA"));
				estareasocioecono.setFechaCrea(rs.getDate("FECHA_CREA"));		
				estareasocioecono.setUsuarioModifica(rs.getString("USUARIO_MODIFICA"));
				estareasocioecono.setFechaModifica(rs.getDate("FECHA_MODIFICA"));		
			return estareasocioecono;
		}
    }

    // ------------- FindByPrimaryKeyQuery -------------------------------
    class FindByPrimaryKeyQuery extends BaseQueryOperation {
		private static final String sql = SELECT
										+ WHERE + " 1=1 ";
    	public FindByPrimaryKeyQuery(DataSource ds) {
    		super(ds,sql);
			compile();
    	}
    	public EstAreaSocioecono runQuery(long id) {
			List result =  execute( new Object[]{new Long(id)});
			if ( result.size() > 0 ) {
        		return (EstAreaSocioecono) result.get(0);
        	} else {
        		return null;
        	}
    	}
    }

    // ------------- FindByIdSolicitudKeyQuery -------------------------------
    class FindByIdSolicitudKeyQuery extends BaseQueryOperation {
		private static final String sql = SELECT
										+ WHERE 
										+ " 1=1 "
										+ " AND ID_EST_SOCIO_ECONOMICO = ? ";
    	public FindByIdSolicitudKeyQuery(DataSource ds) {
    		super(ds,sql);
    		declareParameter( new SqlParameter(Types.INTEGER) );
			compile();
    	}
    	public EstAreaSocioecono runQuery(long idSolicitud) {
			List result =  execute( new Object[]{new Long(idSolicitud)});
			if ( result.size() > 0 ) {
        		return (EstAreaSocioecono) result.get(0);
        	} else {
        		return null;
        	}
    	}
    }

    // ------------- FindByCriteriaQuery ---------------------------------    
    class FindByCriteriaQuery extends BaseQueryOperation {
		private static final String sql = SELECT
										+ WHERE + " 1=1 ";
			//For required criteria elements uncomment required values
			  	  	  					//+ " AND ID = ? "
			  	  	  					//+ " AND ID_EST_SOCIO_ECONOMICO = ? "
			  	  	  					//+ " AND VALOR_EGRESO_F_MES = ? "
			  	  	  					//+ " AND TRABAJA_EPU = ? "
			  	  	  					//+ " AND PROMEDIO_MES_VENTA = ? "
			  	  	  					//+ " AND PROMEDIO_MES_GANANCIA = ? "
			  	  	  					//+ " AND OTRA_ACTIVIDAD = ? "
			  	  	  					//+ " AND ACTIVIDAD_ALTERNA = ? "
			  	  	  					//+ " AND NUMERO_DIA = ? "
			  	  	  					//+ " AND PROMEDIO_MES_VENTA_OA = ? "
			  	  	  					//+ " AND PROMEDIO_MES_GANANCIA_OA = ? "
			  	  	  					//+ " AND OTROS_INGRESOS = ? "
			  	  	  					//+ " AND CONCEPTO_OTROS_INGRESOS = ? "
			  	  	  					//+ " AND VALOR_OTROS_INGRESOS = ? "
			  	  	  					//+ " AND VALOR_INGRESO_F_MES = ? "
			  	  	  					//+ " AND CAPITAL_INVERTIDO = ? "
			  	  	  					//+ " AND PAGO_BODEGA = ? "
			  	  	  					//+ " AND VALOR_PAGO_BODEGA = ? "
			  	  	  					//+ " AND RAZON_VENTA_EPU = ? "
			  	  	  					//+ " AND OTRA_VENTA_EPU = ? "
			  	  	  					//+ " AND ARTE_ALTERNO = ? "
			  	  	  					//+ " AND OTRO_ARTE_ALTERNO = ? "
			  	  	  					//+ " AND OBSERVACION = ? "
			  	  	  					//+ " AND ESTADO = ? "
			  	  	  					//+ " AND USUARIO_CREA = ? "
			  	  	  					//+ " AND FECHA_CREA = ? "
			  	  	  					//+ " AND USUARIO_MODIFICA = ? "
			  	  	  					//+ " AND FECHA_MODIFICA = ? "
										//+ "";
    	public FindByCriteriaQuery(DataSource ds) {
    		super(ds,sql);
    		//For required criteria elements uncomment required values
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.INTEGER) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.DATE) );
			//declareParameter( new SqlParameter(Types.CHAR) );
			//declareParameter( new SqlParameter(Types.DATE) );
			compile();
    	}
    	public EstAreaSocioecono runQuery(EstAreaSocioecono estareasocioecono) {
			List result =  execute( new Object[]{
			//For required criteria elements uncomment required values
				//estareasocioecono.getId(),
				//estareasocioecono.getIdEstSocioEconomico(),
				//estareasocioecono.getValorEgresoFMes(),
				//estareasocioecono.getTrabajaEpu(),
				//estareasocioecono.getPromedioMesVenta(),
				//estareasocioecono.getPromedioMesGanancia(),
				//estareasocioecono.getOtraActividad(),
				//estareasocioecono.getActividadAlterna(),
				//estareasocioecono.getNumeroDia(),
				//estareasocioecono.getPromedioMesVentaOa(),
				//estareasocioecono.getPromedioMesGananciaOa(),
				//estareasocioecono.getOtrosIngresos(),
				//estareasocioecono.getConceptoOtrosIngresos(),
				//estareasocioecono.getValorOtrosIngresos(),
				//estareasocioecono.getValorIngresoFMes(),
				//estareasocioecono.getCapitalInvertido(),
				//estareasocioecono.getPagoBodega(),
				//estareasocioecono.getValorPagoBodega(),
				//estareasocioecono.getRazonVentaEpu(),
				//estareasocioecono.getOtraVentaEpu(),
				//estareasocioecono.getArteAlterno(),
				//estareasocioecono.getOtroArteAlterno(),
				//estareasocioecono.getObservacion(),
				//estareasocioecono.getEstado(),
				//estareasocioecono.getUsuarioCrea(),
				//estareasocioecono.getFechaCrea(),
				//estareasocioecono.getUsuarioModifica(),
				//estareasocioecono.getFechaModifica(),
				});
			if ( result.size() > 0 ) {
        		return (EstAreaSocioecono) result.get(0);
        	} else {
        		return null;
        	}
    	}
    }

    // ------------- FindAllQuery ----------------------------------------    
    class FindAllQuery extends BaseQueryOperation {
		private static final String sql = SELECT
										+ WHERE + " 1=1 ";
    	public FindAllQuery(DataSource ds) {
    		super(ds,sql);
			compile();
    	}
    	public List runQuery() {
			List result =  execute();
			if ( result.size() > 0 ) {
        		return  result;
        	} else {
        		return null;
        	}
    	}
    }

    // ------------- FindByActiveStateQuery  -----------------------------
    class FindByActiveStateQuery extends BaseQueryOperation {
		private static final String sql = SELECT
										+ WHERE;
    	public FindByActiveStateQuery(DataSource ds) {
    		super(ds,sql);
			compile();
    	}
    	public EstAreaSocioecono runQuery(EstAreaSocioecono estareasocioecono) {
			List result =  execute( new Object[]{
			});
			if ( result.size() > 0 ) {
        		return (EstAreaSocioecono) result.get(0);
        	} else {
        		return null;
        	}
    	}
    }

}
